#include "myhead.h"

int *fun()
{
	int m=895; //栈空间，函数调用完毕，栈空间会被释放掉
	printf("fun函数被调用了!\n");
	return &m;
}

int *newfun()
{
	int *p=malloc(4);
	*p=895;
	printf("newfun函数被调用了!\n");
	return p;
}

char *fun1()
{
	char buf[10];
	strcpy(buf,"hehe");
	printf("fun1函数被调用了!\n");
	return buf;
}

char *newfun1()
{
	char *p=malloc(10);
	strcpy(p,"hehe");
	printf("newfun1函数被调用了!\n");
	return p;
}

int main()
{
	int *p=newfun();
	printf("fun的返回值是:%d\n",*p);
	
	char *q=newfun1();
	printf("fun1的返回值是:%s\n",q);
	
	//主动释放堆空间
	free(p);
	free(q);
}